var vm = new Vue({
    el:'#app',
    data:{
        host:'http://127.0.0.1:8000/',
        texts:[],
        navinfo:[]
    },
    mounted:function(){

        this.detail_id = this.get_query_string('detail_id');
        this.fic_id = this.get_query_string('fic_id');
        this.detail_text()
        this.fic()
    },
    methods:{
        fic:function () {
            axios.get(this.host+'nav/',{

            }).then(response=>{
                this.navinfo=response.data

            }).catch(error=>{

            })
        },

         get_query_string: function(name){
            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return decodeURI(r[2])
            }
                return null;
        },


        detail_text:function () {
            axios.get(this.host+'detailtext/'+this.detail_id,{

            }).then(response=>{
                this.texts = response.data
            }).catch(error=>{

            })
        },
        //下一张
        next:function () {
            // alert(this.fic_id)
            window.location='detail.html?detail_id='+parseInt( parseInt(this.detail_id)+1)+'&fic_id='+this.fic_id
        },
        //上一页
         prev:function () {
            var pages = parseInt( parseInt(this.detail_id)-1);
            if (pages==0){
                alert('亲！没有第0章')
            }else {
                window.location = 'detail.html?detail_id='+pages+'&fic_id='+this.fic_id
            }

        },
        //章节目录
        mulu:function () {

            window.location='zhangjie.html?fic_id='+this.fic_id+'&detail_id='+this.detail_id
        },
        detail:function (nav_id) {
            window.location = 'index.html?nav_id='+nav_id
        },
        allfic:function () {
            window.location='allfic.html'
        }








    }
})